﻿// ===============================================================================
// InputCastExceptionEventArgs.cs
// EOS Web Framework
// ===============================================================================
// Copyright (c) EOS Development Group. All rights reserved.
// ===============================================================================

namespace EOS.Framework.Web.Mvc.Controls
{
    using System;
    using EOS.Framework.Tools.Aspects;

    /// <summary>
    /// Event Argument for Events, which occurs, when the form values cannot be casted
    /// to the requested type.
    /// </summary>
    public class InputCastExceptionEventArgs : EventArgs
    {
        /// <summary>
        /// The name of field, which failed to cast.
        /// </summary>
        private string _fieldName;

        /// <summary>
        /// Gets or sets the name of the field, which cannot be casted.
        /// </summary>
        /// <value>The name of the field.</value>
        /// <exception cref="ArgumentNullException"><paramref name="value"/> is 
        /// null (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentException"><paramref name="value"/> is a string
        /// of length 0 or contains only blanks.</exception>
        [NotNullOrEmpty]
        public string FieldName
        {
            get { return _fieldName; }
            set { _fieldName = value; }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InputCastExceptionEventArgs"/> class
        /// with the fieldName.
        /// </summary>
        /// <param name="fieldName">Name of the field, which cannot be casted.
        /// Cannot be null or empty or contains only blanks.</param>
        /// <exception cref="ArgumentNullException"><paramref name="fieldName"/> is 
        /// null (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentException"><paramref name="fieldName"/> is a string
        /// of length 0 or contains only blanks.</exception>
        [ParamNotNullOrEmpty("fieldName")]
        public InputCastExceptionEventArgs(string fieldName)
        {
            this._fieldName = fieldName;
        }
    }
}
